{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "data": {
      "text/plain": "\"\\naggfunc: aggregate function\\n         聚合函数\\n    求和:   sum, 'sum', np.sum\\n    求均值: 'mean', np.mean(默认)\\n    最大值: max, 'max', np.max\\n    最小值: min, 'min', np.min\\n    数量:   'count'\\n\""
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"\n",
    "aggfunc: aggregate function\n",
    "         聚合函数\n",
    "    求和:   sum, 'sum', np.sum\n",
    "    求均值: 'mean', np.mean(默认)\n",
    "    最大值: max, 'max', np.max\n",
    "    最小值: min, 'min', np.min\n",
    "    数量:   'count'\n",
    "\"\"\""
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "data": {
      "text/plain": "             货号  商品名称  尺码         日期  售卖价  实收金额  销量   平台\n0      YZFM1200    夹克   L 2019-09-01  208   166   2  平台A\n1      FLHR1800  短袖T恤  XL 2019-09-01   73    73   1  平台A\n2      LCHM9800  保暖内衣   M 2019-09-01  148   103   1  平台A\n3      FLHR1800  短袖T恤   M 2019-09-01   73    51   1  平台A\n4      HWLA4700  长袖T恤   M 2019-09-01   88    52   1  平台A\n...         ...   ...  ..        ...  ...   ...  ..  ...\n17515  FLHR1800  短袖T恤  XL 2019-06-30   73    65   1  平台B\n17516  QTVW5600   羽绒服   M 2019-06-30  538   322   1  平台B\n17517  QTVW5600   羽绒服  XL 2019-06-30  538   269   1  平台B\n17518  LCHM9800  保暖内衣   M 2019-06-30  148   103   1  平台B\n17519  HWLA4700  长袖T恤   L 2019-06-30   88    70   1  平台B\n\n[17520 rows x 8 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>货号</th>\n      <th>商品名称</th>\n      <th>尺码</th>\n      <th>日期</th>\n      <th>售卖价</th>\n      <th>实收金额</th>\n      <th>销量</th>\n      <th>平台</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>YZFM1200</td>\n      <td>夹克</td>\n      <td>L</td>\n      <td>2019-09-01</td>\n      <td>208</td>\n      <td>166</td>\n      <td>2</td>\n      <td>平台A</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>FLHR1800</td>\n      <td>短袖T恤</td>\n      <td>XL</td>\n      <td>2019-09-01</td>\n      <td>73</td>\n      <td>73</td>\n      <td>1</td>\n      <td>平台A</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>LCHM9800</td>\n      <td>保暖内衣</td>\n      <td>M</td>\n      <td>2019-09-01</td>\n      <td>148</td>\n      <td>103</td>\n      <td>1</td>\n      <td>平台A</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>FLHR1800</td>\n      <td>短袖T恤</td>\n      <td>M</td>\n      <td>2019-09-01</td>\n      <td>73</td>\n      <td>51</td>\n      <td>1</td>\n      <td>平台A</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>HWLA4700</td>\n      <td>长袖T恤</td>\n      <td>M</td>\n      <td>2019-09-01</td>\n      <td>88</td>\n      <td>52</td>\n      <td>1</td>\n      <td>平台A</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>17515</th>\n      <td>FLHR1800</td>\n      <td>短袖T恤</td>\n      <td>XL</td>\n      <td>2019-06-30</td>\n      <td>73</td>\n      <td>65</td>\n      <td>1</td>\n      <td>平台B</td>\n    </tr>\n    <tr>\n      <th>17516</th>\n      <td>QTVW5600</td>\n      <td>羽绒服</td>\n      <td>M</td>\n      <td>2019-06-30</td>\n      <td>538</td>\n      <td>322</td>\n      <td>1</td>\n      <td>平台B</td>\n    </tr>\n    <tr>\n      <th>17517</th>\n      <td>QTVW5600</td>\n      <td>羽绒服</td>\n      <td>XL</td>\n      <td>2019-06-30</td>\n      <td>538</td>\n      <td>269</td>\n      <td>1</td>\n      <td>平台B</td>\n    </tr>\n    <tr>\n      <th>17518</th>\n      <td>LCHM9800</td>\n      <td>保暖内衣</td>\n      <td>M</td>\n      <td>2019-06-30</td>\n      <td>148</td>\n      <td>103</td>\n      <td>1</td>\n      <td>平台B</td>\n    </tr>\n    <tr>\n      <th>17519</th>\n      <td>HWLA4700</td>\n      <td>长袖T恤</td>\n      <td>L</td>\n      <td>2019-06-30</td>\n      <td>88</td>\n      <td>70</td>\n      <td>1</td>\n      <td>平台B</td>\n    </tr>\n  </tbody>\n</table>\n<p>17520 rows × 8 columns</p>\n</div>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_excel('2019销售总表.xlsx').convert_dtypes()\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "data": {
      "text/plain": "货号              string\n商品名称            string\n尺码              string\n日期      datetime64[ns]\n售卖价              Int64\n实收金额             Int64\n销量               Int64\n平台              string\ndtype: object"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "            销量\n货号            \nAGDH5500  1832\nAXTB3200  1870\nFLHR1800  1862\nHWLA4700  1859\nLCHM9800  1806\nPWDK9200  1797\nQTVW5600  1835\nUQNA9200  1850\nVBOY1800  1705\nXDQV5600  1844\nXHQA3700  1878\nYZFM1200  1741",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>销量</th>\n    </tr>\n    <tr>\n      <th>货号</th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>AGDH5500</th>\n      <td>1832</td>\n    </tr>\n    <tr>\n      <th>AXTB3200</th>\n      <td>1870</td>\n    </tr>\n    <tr>\n      <th>FLHR1800</th>\n      <td>1862</td>\n    </tr>\n    <tr>\n      <th>HWLA4700</th>\n      <td>1859</td>\n    </tr>\n    <tr>\n      <th>LCHM9800</th>\n      <td>1806</td>\n    </tr>\n    <tr>\n      <th>PWDK9200</th>\n      <td>1797</td>\n    </tr>\n    <tr>\n      <th>QTVW5600</th>\n      <td>1835</td>\n    </tr>\n    <tr>\n      <th>UQNA9200</th>\n      <td>1850</td>\n    </tr>\n    <tr>\n      <th>VBOY1800</th>\n      <td>1705</td>\n    </tr>\n    <tr>\n      <th>XDQV5600</th>\n      <td>1844</td>\n    </tr>\n    <tr>\n      <th>XHQA3700</th>\n      <td>1878</td>\n    </tr>\n    <tr>\n      <th>YZFM1200</th>\n      <td>1741</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.pivot_table(\n",
    "    df,\n",
    "    index='货号',\n",
    "    values='销量',\n",
    "    aggfunc=sum\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "data": {
      "text/plain": "           sum      mean\n            销量        销量\n货号                      \nAGDH5500  1832  1.249659\nAXTB3200  1870  1.250000\nFLHR1800  1862  1.269257\nHWLA4700  1859  1.240160\nLCHM9800  1806  1.242091\nPWDK9200  1797  1.224949\nQTVW5600  1835  1.253415\nUQNA9200  1850  1.266256\nVBOY1800  1705  1.241806\nXDQV5600  1844  1.250169\nXHQA3700  1878  1.270636\nYZFM1200  1741  1.226056",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead tr th {\n        text-align: left;\n    }\n\n    .dataframe thead tr:last-of-type th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr>\n      <th></th>\n      <th>sum</th>\n      <th>mean</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th>销量</th>\n      <th>销量</th>\n    </tr>\n    <tr>\n      <th>货号</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>AGDH5500</th>\n      <td>1832</td>\n      <td>1.249659</td>\n    </tr>\n    <tr>\n      <th>AXTB3200</th>\n      <td>1870</td>\n      <td>1.250000</td>\n    </tr>\n    <tr>\n      <th>FLHR1800</th>\n      <td>1862</td>\n      <td>1.269257</td>\n    </tr>\n    <tr>\n      <th>HWLA4700</th>\n      <td>1859</td>\n      <td>1.240160</td>\n    </tr>\n    <tr>\n      <th>LCHM9800</th>\n      <td>1806</td>\n      <td>1.242091</td>\n    </tr>\n    <tr>\n      <th>PWDK9200</th>\n      <td>1797</td>\n      <td>1.224949</td>\n    </tr>\n    <tr>\n      <th>QTVW5600</th>\n      <td>1835</td>\n      <td>1.253415</td>\n    </tr>\n    <tr>\n      <th>UQNA9200</th>\n      <td>1850</td>\n      <td>1.266256</td>\n    </tr>\n    <tr>\n      <th>VBOY1800</th>\n      <td>1705</td>\n      <td>1.241806</td>\n    </tr>\n    <tr>\n      <th>XDQV5600</th>\n      <td>1844</td>\n      <td>1.250169</td>\n    </tr>\n    <tr>\n      <th>XHQA3700</th>\n      <td>1878</td>\n      <td>1.270636</td>\n    </tr>\n    <tr>\n      <th>YZFM1200</th>\n      <td>1741</td>\n      <td>1.226056</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.pivot_table(\n",
    "    df,\n",
    "    index='货号',\n",
    "    values='销量',\n",
    "    aggfunc=[sum, 'mean']\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "data": {
      "text/plain": "            实收金额    销量\n货号                    \nAGDH5500  261815  1832\nAXTB3200  299665  1870\nFLHR1800   80515  1862\nHWLA4700   97728  1859\nLCHM9800  162112  1806\nPWDK9200  194394  1797\nQTVW5600  599988  1835\nUQNA9200  219979  1850\nVBOY1800  369494  1705\nXDQV5600  181813  1844\nXHQA3700  659872  1878\nYZFM1200  220054  1741",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>实收金额</th>\n      <th>销量</th>\n    </tr>\n    <tr>\n      <th>货号</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>AGDH5500</th>\n      <td>261815</td>\n      <td>1832</td>\n    </tr>\n    <tr>\n      <th>AXTB3200</th>\n      <td>299665</td>\n      <td>1870</td>\n    </tr>\n    <tr>\n      <th>FLHR1800</th>\n      <td>80515</td>\n      <td>1862</td>\n    </tr>\n    <tr>\n      <th>HWLA4700</th>\n      <td>97728</td>\n      <td>1859</td>\n    </tr>\n    <tr>\n      <th>LCHM9800</th>\n      <td>162112</td>\n      <td>1806</td>\n    </tr>\n    <tr>\n      <th>PWDK9200</th>\n      <td>194394</td>\n      <td>1797</td>\n    </tr>\n    <tr>\n      <th>QTVW5600</th>\n      <td>599988</td>\n      <td>1835</td>\n    </tr>\n    <tr>\n      <th>UQNA9200</th>\n      <td>219979</td>\n      <td>1850</td>\n    </tr>\n    <tr>\n      <th>VBOY1800</th>\n      <td>369494</td>\n      <td>1705</td>\n    </tr>\n    <tr>\n      <th>XDQV5600</th>\n      <td>181813</td>\n      <td>1844</td>\n    </tr>\n    <tr>\n      <th>XHQA3700</th>\n      <td>659872</td>\n      <td>1878</td>\n    </tr>\n    <tr>\n      <th>YZFM1200</th>\n      <td>220054</td>\n      <td>1741</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.pivot_table(\n",
    "    df,\n",
    "    index='货号',\n",
    "    values=['销量', '实收金额'],\n",
    "    aggfunc=sum\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [
    {
     "data": {
      "text/plain": "                实收金额    销量\n货号                        \nAGDH5500  178.591405  1832\nAXTB3200  200.310829  1870\nFLHR1800   54.884117  1862\nHWLA4700   65.195464  1859\nLCHM9800  111.493810  1806\nPWDK9200  132.511247  1797\nQTVW5600  409.827869  1835\nUQNA9200  150.567420  1850\nVBOY1800  269.114348  1705\nXDQV5600  123.263051  1844\nXHQA3700  446.462788  1878\nYZFM1200  154.967606  1741",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>实收金额</th>\n      <th>销量</th>\n    </tr>\n    <tr>\n      <th>货号</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>AGDH5500</th>\n      <td>178.591405</td>\n      <td>1832</td>\n    </tr>\n    <tr>\n      <th>AXTB3200</th>\n      <td>200.310829</td>\n      <td>1870</td>\n    </tr>\n    <tr>\n      <th>FLHR1800</th>\n      <td>54.884117</td>\n      <td>1862</td>\n    </tr>\n    <tr>\n      <th>HWLA4700</th>\n      <td>65.195464</td>\n      <td>1859</td>\n    </tr>\n    <tr>\n      <th>LCHM9800</th>\n      <td>111.493810</td>\n      <td>1806</td>\n    </tr>\n    <tr>\n      <th>PWDK9200</th>\n      <td>132.511247</td>\n      <td>1797</td>\n    </tr>\n    <tr>\n      <th>QTVW5600</th>\n      <td>409.827869</td>\n      <td>1835</td>\n    </tr>\n    <tr>\n      <th>UQNA9200</th>\n      <td>150.567420</td>\n      <td>1850</td>\n    </tr>\n    <tr>\n      <th>VBOY1800</th>\n      <td>269.114348</td>\n      <td>1705</td>\n    </tr>\n    <tr>\n      <th>XDQV5600</th>\n      <td>123.263051</td>\n      <td>1844</td>\n    </tr>\n    <tr>\n      <th>XHQA3700</th>\n      <td>446.462788</td>\n      <td>1878</td>\n    </tr>\n    <tr>\n      <th>YZFM1200</th>\n      <td>154.967606</td>\n      <td>1741</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.pivot_table(\n",
    "    df,\n",
    "    index='货号',\n",
    "    values=['销量', '实收金额'],\n",
    "    aggfunc={\n",
    "       '销量': sum,\n",
    "       '实收金额': 'mean'\n",
    "    }\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "data": {
      "text/plain": "平台            平台A  平台B\n货号       尺码           \nAGDH5500 L    239  254\n         M    348  296\n         S    103   78\n         XL   199  169\n         XXL   71   75\nAXTB3200 L    266  271\n         M    332  356\n         S     96   68\n         XL   172  164\n         XXL   74   71\nFLHR1800 L    291  263\n         M    331  355\n         S     75   71\n         XL   184  149\n         XXL   80   63\nHWLA4700 L    242  279\n         M    337  326\n         S     80   91\n         XL   170  168\n         XXL   82   84\nLCHM9800 L    258  230\n         M    308  327\n         S     69  109\n         XL   183  168\n         XXL   70   84\nPWDK9200 L    245  233\n         M    344  316\n         S     82   82\n         XL   165  147\n         XXL   83  100\nQTVW5600 L    261  257\n         M    327  344\n         S     89   70\n         XL   152  176\n         XXL   85   74\nUQNA9200 L    252  240\n         M    359  332\n         S     84   78\n         XL   157  169\n         XXL  106   73\nVBOY1800 L    205  240\n         M    335  316\n         S     85   76\n         XL   145  144\n         XXL   83   76\nXDQV5600 L    226  256\n         M    322  347\n         S     80   96\n         XL   176  175\n         XXL   79   87\nXHQA3700 L    263  224\n         M    378  341\n         S     94   95\n         XL   148  169\n         XXL   71   95\nYZFM1200 L    249  240\n         M    353  297\n         S     86   56\n         XL   153  161\n         XXL   65   81",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>平台</th>\n      <th>平台A</th>\n      <th>平台B</th>\n    </tr>\n    <tr>\n      <th>货号</th>\n      <th>尺码</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">AGDH5500</th>\n      <th>L</th>\n      <td>239</td>\n      <td>254</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>348</td>\n      <td>296</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>103</td>\n      <td>78</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>199</td>\n      <td>169</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>71</td>\n      <td>75</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">AXTB3200</th>\n      <th>L</th>\n      <td>266</td>\n      <td>271</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>332</td>\n      <td>356</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>96</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>172</td>\n      <td>164</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>74</td>\n      <td>71</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">FLHR1800</th>\n      <th>L</th>\n      <td>291</td>\n      <td>263</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>331</td>\n      <td>355</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>75</td>\n      <td>71</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>184</td>\n      <td>149</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>80</td>\n      <td>63</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">HWLA4700</th>\n      <th>L</th>\n      <td>242</td>\n      <td>279</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>337</td>\n      <td>326</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>80</td>\n      <td>91</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>170</td>\n      <td>168</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>82</td>\n      <td>84</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">LCHM9800</th>\n      <th>L</th>\n      <td>258</td>\n      <td>230</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>308</td>\n      <td>327</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>69</td>\n      <td>109</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>183</td>\n      <td>168</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>70</td>\n      <td>84</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">PWDK9200</th>\n      <th>L</th>\n      <td>245</td>\n      <td>233</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>344</td>\n      <td>316</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>82</td>\n      <td>82</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>165</td>\n      <td>147</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>83</td>\n      <td>100</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">QTVW5600</th>\n      <th>L</th>\n      <td>261</td>\n      <td>257</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>327</td>\n      <td>344</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>89</td>\n      <td>70</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>152</td>\n      <td>176</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>85</td>\n      <td>74</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">UQNA9200</th>\n      <th>L</th>\n      <td>252</td>\n      <td>240</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>359</td>\n      <td>332</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>84</td>\n      <td>78</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>157</td>\n      <td>169</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>106</td>\n      <td>73</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">VBOY1800</th>\n      <th>L</th>\n      <td>205</td>\n      <td>240</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>335</td>\n      <td>316</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>85</td>\n      <td>76</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>145</td>\n      <td>144</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>83</td>\n      <td>76</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">XDQV5600</th>\n      <th>L</th>\n      <td>226</td>\n      <td>256</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>322</td>\n      <td>347</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>80</td>\n      <td>96</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>176</td>\n      <td>175</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>79</td>\n      <td>87</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">XHQA3700</th>\n      <th>L</th>\n      <td>263</td>\n      <td>224</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>378</td>\n      <td>341</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>94</td>\n      <td>95</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>148</td>\n      <td>169</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>71</td>\n      <td>95</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">YZFM1200</th>\n      <th>L</th>\n      <td>249</td>\n      <td>240</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>353</td>\n      <td>297</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>86</td>\n      <td>56</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>153</td>\n      <td>161</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>65</td>\n      <td>81</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.pivot_table(\n",
    "    df,\n",
    "    index=['货号', '尺码'],\n",
    "    columns='平台',\n",
    "    values='销量',\n",
    "    aggfunc=sum\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "data": {
      "text/plain": "平台           平台A               平台B             \n日期             1   2    3    4   1   2    3   4\n货号       尺码                                    \nAGDH5500 L    54  62   69   54  64  47   75  68\n         M    65  85   99   99  77  86   61  72\n         S    18  30   38   17  17  21   16  24\n         XL   48  40   60   51  49  30   40  50\n         XXL  18  19   17   17  18  28   14  15\nAXTB3200 L    57  83   57   69  59  63   76  73\n         M    78  71   92   91  89  95   86  86\n         S    22  14   38   22  18  17   17  16\n         XL   44  41   44   43  35  38   52  39\n         XXL  26  22   15   11  11  16   26  18\nFLHR1800 L    83  83   59   66  58  69   70  66\n         M    89  82   81   79  91  86   98  80\n         S    24  23   13   15  21  17   17  16\n         XL   41  55   45   43  32  26   45  46\n         XXL  22  26   17   15  16  24   11  12\nHWLA4700 L    52  78   60   52  59  77   85  58\n         M    91  82   85   79  64  86   83  93\n         S    20  27   17   16  28  25   23  15\n         XL   47  34   46   43  40  23   39  66\n         XXL  29  14   22   17  18  25   24  17\nLCHM9800 L    54  56   75   73  62  55   47  66\n         M    74  84   75   75  92  94   58  83\n         S    21  14   18   16  32  27   28  22\n         XL   36  46   48   53  32  50   43  43\n         XXL  18  19   19   14  26  14   20  24\nPWDK9200 L    48  64   68   65  52  52   58  71\n         M    97  76   91   80  80  87   69  80\n         S    19  27   23   13  16  17   24  25\n         XL   43  36   45   41  35  56   29  27\n         XXL  18  30   17   18  20  32   25  23\nQTVW5600 L    64  65   70   62  59  62   68  68\n         M    67  69   89  102  80  81   84  99\n         S    16  28   26   19  13  11   20  26\n         XL   32  39   37   44  38  36   43  59\n         XXL  23  24   17   21  20  12   26  16\nUQNA9200 L    61  57   59   75  73  63   51  53\n         M    86  94  103   76  79  73   89  91\n         S    26  18   19   21  23  24   18  13\n         XL   31  34   48   44  43  46   46  34\n         XXL  28  23   28   27  15  29   11  18\nVBOY1800 L    54  47   59   45  63  58   72  47\n         M    93  86   82   74  87  77   78  74\n         S    30  12   17   26  25  20   16  15\n         XL   30  44   22   49  42  42   33  27\n         XXL  17  13   24   29  12  18   26  20\nXDQV5600 L    61  65   38   62  61  71   53  71\n         M    87  69   76   90  94  87   81  85\n         S    18  19   24   19  20  31   25  20\n         XL   46  49   32   49  50  38   39  48\n         XXL  23  17   20   19  15  28   24  20\nXHQA3700 L    68  67   63   65  60  51   63  50\n         M    93  96   82  107  74  77  100  90\n         S    24  20   19   31  33  21   16  25\n         XL   44  31   34   39  36  32   48  53\n         XXL  23  14   22   12  18  20   32  25\nYZFM1200 L    50  62   62   75  58  68   60  54\n         M    84  97   88   84  70  80   75  72\n         S    17  18   25   26  10  20   10  16\n         XL   32  44   28   49  36  45   42  38\n         XXL  18  14   20   13  24  20   21  16",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead tr th {\n        text-align: left;\n    }\n\n    .dataframe thead tr:last-of-type th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr>\n      <th></th>\n      <th>平台</th>\n      <th colspan=\"4\" halign=\"left\">平台A</th>\n      <th colspan=\"4\" halign=\"left\">平台B</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th>日期</th>\n      <th>1</th>\n      <th>2</th>\n      <th>3</th>\n      <th>4</th>\n      <th>1</th>\n      <th>2</th>\n      <th>3</th>\n      <th>4</th>\n    </tr>\n    <tr>\n      <th>货号</th>\n      <th>尺码</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">AGDH5500</th>\n      <th>L</th>\n      <td>54</td>\n      <td>62</td>\n      <td>69</td>\n      <td>54</td>\n      <td>64</td>\n      <td>47</td>\n      <td>75</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>65</td>\n      <td>85</td>\n      <td>99</td>\n      <td>99</td>\n      <td>77</td>\n      <td>86</td>\n      <td>61</td>\n      <td>72</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>18</td>\n      <td>30</td>\n      <td>38</td>\n      <td>17</td>\n      <td>17</td>\n      <td>21</td>\n      <td>16</td>\n      <td>24</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>48</td>\n      <td>40</td>\n      <td>60</td>\n      <td>51</td>\n      <td>49</td>\n      <td>30</td>\n      <td>40</td>\n      <td>50</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>18</td>\n      <td>19</td>\n      <td>17</td>\n      <td>17</td>\n      <td>18</td>\n      <td>28</td>\n      <td>14</td>\n      <td>15</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">AXTB3200</th>\n      <th>L</th>\n      <td>57</td>\n      <td>83</td>\n      <td>57</td>\n      <td>69</td>\n      <td>59</td>\n      <td>63</td>\n      <td>76</td>\n      <td>73</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>78</td>\n      <td>71</td>\n      <td>92</td>\n      <td>91</td>\n      <td>89</td>\n      <td>95</td>\n      <td>86</td>\n      <td>86</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>22</td>\n      <td>14</td>\n      <td>38</td>\n      <td>22</td>\n      <td>18</td>\n      <td>17</td>\n      <td>17</td>\n      <td>16</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>44</td>\n      <td>41</td>\n      <td>44</td>\n      <td>43</td>\n      <td>35</td>\n      <td>38</td>\n      <td>52</td>\n      <td>39</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>26</td>\n      <td>22</td>\n      <td>15</td>\n      <td>11</td>\n      <td>11</td>\n      <td>16</td>\n      <td>26</td>\n      <td>18</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">FLHR1800</th>\n      <th>L</th>\n      <td>83</td>\n      <td>83</td>\n      <td>59</td>\n      <td>66</td>\n      <td>58</td>\n      <td>69</td>\n      <td>70</td>\n      <td>66</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>89</td>\n      <td>82</td>\n      <td>81</td>\n      <td>79</td>\n      <td>91</td>\n      <td>86</td>\n      <td>98</td>\n      <td>80</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>24</td>\n      <td>23</td>\n      <td>13</td>\n      <td>15</td>\n      <td>21</td>\n      <td>17</td>\n      <td>17</td>\n      <td>16</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>41</td>\n      <td>55</td>\n      <td>45</td>\n      <td>43</td>\n      <td>32</td>\n      <td>26</td>\n      <td>45</td>\n      <td>46</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>22</td>\n      <td>26</td>\n      <td>17</td>\n      <td>15</td>\n      <td>16</td>\n      <td>24</td>\n      <td>11</td>\n      <td>12</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">HWLA4700</th>\n      <th>L</th>\n      <td>52</td>\n      <td>78</td>\n      <td>60</td>\n      <td>52</td>\n      <td>59</td>\n      <td>77</td>\n      <td>85</td>\n      <td>58</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>91</td>\n      <td>82</td>\n      <td>85</td>\n      <td>79</td>\n      <td>64</td>\n      <td>86</td>\n      <td>83</td>\n      <td>93</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>20</td>\n      <td>27</td>\n      <td>17</td>\n      <td>16</td>\n      <td>28</td>\n      <td>25</td>\n      <td>23</td>\n      <td>15</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>47</td>\n      <td>34</td>\n      <td>46</td>\n      <td>43</td>\n      <td>40</td>\n      <td>23</td>\n      <td>39</td>\n      <td>66</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>29</td>\n      <td>14</td>\n      <td>22</td>\n      <td>17</td>\n      <td>18</td>\n      <td>25</td>\n      <td>24</td>\n      <td>17</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">LCHM9800</th>\n      <th>L</th>\n      <td>54</td>\n      <td>56</td>\n      <td>75</td>\n      <td>73</td>\n      <td>62</td>\n      <td>55</td>\n      <td>47</td>\n      <td>66</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>74</td>\n      <td>84</td>\n      <td>75</td>\n      <td>75</td>\n      <td>92</td>\n      <td>94</td>\n      <td>58</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>21</td>\n      <td>14</td>\n      <td>18</td>\n      <td>16</td>\n      <td>32</td>\n      <td>27</td>\n      <td>28</td>\n      <td>22</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>36</td>\n      <td>46</td>\n      <td>48</td>\n      <td>53</td>\n      <td>32</td>\n      <td>50</td>\n      <td>43</td>\n      <td>43</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>18</td>\n      <td>19</td>\n      <td>19</td>\n      <td>14</td>\n      <td>26</td>\n      <td>14</td>\n      <td>20</td>\n      <td>24</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">PWDK9200</th>\n      <th>L</th>\n      <td>48</td>\n      <td>64</td>\n      <td>68</td>\n      <td>65</td>\n      <td>52</td>\n      <td>52</td>\n      <td>58</td>\n      <td>71</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>97</td>\n      <td>76</td>\n      <td>91</td>\n      <td>80</td>\n      <td>80</td>\n      <td>87</td>\n      <td>69</td>\n      <td>80</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>19</td>\n      <td>27</td>\n      <td>23</td>\n      <td>13</td>\n      <td>16</td>\n      <td>17</td>\n      <td>24</td>\n      <td>25</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>43</td>\n      <td>36</td>\n      <td>45</td>\n      <td>41</td>\n      <td>35</td>\n      <td>56</td>\n      <td>29</td>\n      <td>27</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>18</td>\n      <td>30</td>\n      <td>17</td>\n      <td>18</td>\n      <td>20</td>\n      <td>32</td>\n      <td>25</td>\n      <td>23</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">QTVW5600</th>\n      <th>L</th>\n      <td>64</td>\n      <td>65</td>\n      <td>70</td>\n      <td>62</td>\n      <td>59</td>\n      <td>62</td>\n      <td>68</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>67</td>\n      <td>69</td>\n      <td>89</td>\n      <td>102</td>\n      <td>80</td>\n      <td>81</td>\n      <td>84</td>\n      <td>99</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>16</td>\n      <td>28</td>\n      <td>26</td>\n      <td>19</td>\n      <td>13</td>\n      <td>11</td>\n      <td>20</td>\n      <td>26</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>32</td>\n      <td>39</td>\n      <td>37</td>\n      <td>44</td>\n      <td>38</td>\n      <td>36</td>\n      <td>43</td>\n      <td>59</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>23</td>\n      <td>24</td>\n      <td>17</td>\n      <td>21</td>\n      <td>20</td>\n      <td>12</td>\n      <td>26</td>\n      <td>16</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">UQNA9200</th>\n      <th>L</th>\n      <td>61</td>\n      <td>57</td>\n      <td>59</td>\n      <td>75</td>\n      <td>73</td>\n      <td>63</td>\n      <td>51</td>\n      <td>53</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>86</td>\n      <td>94</td>\n      <td>103</td>\n      <td>76</td>\n      <td>79</td>\n      <td>73</td>\n      <td>89</td>\n      <td>91</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>26</td>\n      <td>18</td>\n      <td>19</td>\n      <td>21</td>\n      <td>23</td>\n      <td>24</td>\n      <td>18</td>\n      <td>13</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>31</td>\n      <td>34</td>\n      <td>48</td>\n      <td>44</td>\n      <td>43</td>\n      <td>46</td>\n      <td>46</td>\n      <td>34</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>28</td>\n      <td>23</td>\n      <td>28</td>\n      <td>27</td>\n      <td>15</td>\n      <td>29</td>\n      <td>11</td>\n      <td>18</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">VBOY1800</th>\n      <th>L</th>\n      <td>54</td>\n      <td>47</td>\n      <td>59</td>\n      <td>45</td>\n      <td>63</td>\n      <td>58</td>\n      <td>72</td>\n      <td>47</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>93</td>\n      <td>86</td>\n      <td>82</td>\n      <td>74</td>\n      <td>87</td>\n      <td>77</td>\n      <td>78</td>\n      <td>74</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>30</td>\n      <td>12</td>\n      <td>17</td>\n      <td>26</td>\n      <td>25</td>\n      <td>20</td>\n      <td>16</td>\n      <td>15</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>30</td>\n      <td>44</td>\n      <td>22</td>\n      <td>49</td>\n      <td>42</td>\n      <td>42</td>\n      <td>33</td>\n      <td>27</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>17</td>\n      <td>13</td>\n      <td>24</td>\n      <td>29</td>\n      <td>12</td>\n      <td>18</td>\n      <td>26</td>\n      <td>20</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">XDQV5600</th>\n      <th>L</th>\n      <td>61</td>\n      <td>65</td>\n      <td>38</td>\n      <td>62</td>\n      <td>61</td>\n      <td>71</td>\n      <td>53</td>\n      <td>71</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>87</td>\n      <td>69</td>\n      <td>76</td>\n      <td>90</td>\n      <td>94</td>\n      <td>87</td>\n      <td>81</td>\n      <td>85</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>18</td>\n      <td>19</td>\n      <td>24</td>\n      <td>19</td>\n      <td>20</td>\n      <td>31</td>\n      <td>25</td>\n      <td>20</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>46</td>\n      <td>49</td>\n      <td>32</td>\n      <td>49</td>\n      <td>50</td>\n      <td>38</td>\n      <td>39</td>\n      <td>48</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>23</td>\n      <td>17</td>\n      <td>20</td>\n      <td>19</td>\n      <td>15</td>\n      <td>28</td>\n      <td>24</td>\n      <td>20</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">XHQA3700</th>\n      <th>L</th>\n      <td>68</td>\n      <td>67</td>\n      <td>63</td>\n      <td>65</td>\n      <td>60</td>\n      <td>51</td>\n      <td>63</td>\n      <td>50</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>93</td>\n      <td>96</td>\n      <td>82</td>\n      <td>107</td>\n      <td>74</td>\n      <td>77</td>\n      <td>100</td>\n      <td>90</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>24</td>\n      <td>20</td>\n      <td>19</td>\n      <td>31</td>\n      <td>33</td>\n      <td>21</td>\n      <td>16</td>\n      <td>25</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>44</td>\n      <td>31</td>\n      <td>34</td>\n      <td>39</td>\n      <td>36</td>\n      <td>32</td>\n      <td>48</td>\n      <td>53</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>23</td>\n      <td>14</td>\n      <td>22</td>\n      <td>12</td>\n      <td>18</td>\n      <td>20</td>\n      <td>32</td>\n      <td>25</td>\n    </tr>\n    <tr>\n      <th rowspan=\"5\" valign=\"top\">YZFM1200</th>\n      <th>L</th>\n      <td>50</td>\n      <td>62</td>\n      <td>62</td>\n      <td>75</td>\n      <td>58</td>\n      <td>68</td>\n      <td>60</td>\n      <td>54</td>\n    </tr>\n    <tr>\n      <th>M</th>\n      <td>84</td>\n      <td>97</td>\n      <td>88</td>\n      <td>84</td>\n      <td>70</td>\n      <td>80</td>\n      <td>75</td>\n      <td>72</td>\n    </tr>\n    <tr>\n      <th>S</th>\n      <td>17</td>\n      <td>18</td>\n      <td>25</td>\n      <td>26</td>\n      <td>10</td>\n      <td>20</td>\n      <td>10</td>\n      <td>16</td>\n    </tr>\n    <tr>\n      <th>XL</th>\n      <td>32</td>\n      <td>44</td>\n      <td>28</td>\n      <td>49</td>\n      <td>36</td>\n      <td>45</td>\n      <td>42</td>\n      <td>38</td>\n    </tr>\n    <tr>\n      <th>XXL</th>\n      <td>18</td>\n      <td>14</td>\n      <td>20</td>\n      <td>13</td>\n      <td>24</td>\n      <td>20</td>\n      <td>21</td>\n      <td>16</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.pivot_table(\n",
    "    df,\n",
    "    index=['货号', '尺码'],\n",
    "    columns=[\n",
    "        '平台',\n",
    "        df['日期'].dt.quarter],\n",
    "    values='销量',\n",
    "    aggfunc=sum\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}